﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace QQForm
{
    public static class QQMD5
    {
        /// <summary>
        ///   //这里是调用方法
        ///   
        ///   string url = HttpUtility.UrlEncode("http://xiaoyou.qq.com/index.php?mod=login");
        ///下面参数中的u是QQ号码,p是加密后的密码字符串,每次都不同，verifycode是验证码
        ///string postData = "u=" + this.textBox1.Text + "&p=" + pwd + "&verifycode=" + this.textBox3.Text + "&aid=15000102&u1=" + url + "&fp=&h=1&ptredirect=1&ptlang=0&form_ui=1&dumy=";
        ///
        ///string content = "u=" + this.textBox1.Text + "&p=" + getMd5Hash2(getMd5Hash(this.textBox2.Text).ToUpper() + this.textBox3.Text.ToUpper()).ToUpper() + "&verifycode=" + this.textBox3.Text.ToUpper() + "&aid=15000102&u1=" + url + "&fp=&h=1&ptredirect=1&ptlang=0&form_ui=1&dumy=";
        ///    
        /// </summary>
    

        public static  string getMd5Hash(string input)
        {
            MD5 md = MD5.Create();
            byte[] buffer = md.ComputeHash(Encoding.Default.GetBytes(input));
            buffer = md.ComputeHash(buffer);
            buffer = md.ComputeHash(buffer);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < buffer.Length; i++)
            {
                builder.Append(buffer[i].ToString("x2"));
            }
            return builder.ToString();
        }

        public static string getMd5Hash2(string input)
        {
            byte[] buffer = MD5.Create().ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < buffer.Length; i++)
            {
                builder.Append(buffer[i].ToString("x2"));
            }
            return builder.ToString();
        }
        /*{获取服务器时间}
function TE_Cmd.GetfarmTime: Integer;
var
  BaseTime:TDateTime;
  TotalSecond:Integer;
begin
  BaseTime:= EncodeDateTime(1970,1,1,8,0,0,0);
  TotalSecond := round(abs(IncSecond(BaseTime))*24*60*60);
  Result := round(abs(IncSecond(Now))*24*60*60)-TotalSecond;
end;*/
        public static string getFarmTime()
        {

        }
        /*经几组数据测试总结得出farmKey公式:
farmKey=md5(farmTime+substr(sdoit78sdopig7w34057,farmTime%10,20))
*/
        public static string getFarmKey()
        {

        }
    }
}
